package com.kangye.exam.service.serviceimpl;

import com.kangye.exam.bean.Grade;
import com.kangye.exam.dao.GradeDao;
import com.kangye.exam.service.GradeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service(value = "gradeService")
public class GradeServiceImpl implements GradeService {

    @Resource
    private GradeDao gradeDao;

    @Override
    public List<Grade> findAll() {
        return gradeDao.selectALL();
    }

    @Override
    public int delete(Integer id) {
        Map<String, Object> map = new HashMap<>();
        map.put("gradeId", id);
        return gradeDao.deleteByPrimaryKey(map);
    }

    @Override
    public Grade selectById(Integer id) {
        Map<String, Object> map = new HashMap<>();
        map.put("gradeId", id);
        return gradeDao.selectByPrimaryKey(map);
    }

    @Override
    public int insert(Grade grade) {
        return gradeDao.insertSelective(grade);
    }

    @Override
    public int update(Grade grade) {
        return gradeDao.updateByPrimaryKeySelective(grade);
    }

    @Override
    public List<Grade> selectByParm(String grade) {
        Map<String, Object> map = new HashMap<>();
        map.put("grade", grade);
        return gradeDao.selectByParm(map);
    }
}
